<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/6/8
  Time: 16:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>角色修改</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
</head>
<body>
<form class="layui-form" action="${pageContext.request.contextPath}/role/update" method="post">
    <div class="layui-form-item">
    <input type="hidden" name="id" value="${role.id}">
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色名</label>
        <div class="layui-input-inline">
            <input type="text" name="rolename" value="${role.rolename}" placeholder="请输入角色名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状 态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="0" <c:if test="${role.status='0'}">checked</c:if>  title="注销">
            <input type="radio" name="status" value="1" <c:if test="${role.status='1'}">checked</c:if>  title="正常" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">操作人</label>
        <div class="layui-input-inline">
            <input type="text" name="operator" value="${sessionScope.admin.id}" placeholder="操作人" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-inline">
            <textarea type="text" name="explain" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <input type="submit" style="margin-left: 100px" lay-submit class="layui-btn" name="修改">
    </div>
</form>
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script>
    layui.use(['layer','form','jquery'],function () {
        var layer=layui.layer
            , form=layui.form;
        var $=layui.$;
        //异步提交表单
        form.on("submit(update)",function (data) {
            $.post("${pageContext.request.contextPath}/role/update2",data.filed,function (result) {
                  if (result.code==0){
                      layer.msg("修改成功!");
                      //刷新父窗口内容
                      parent.layui.table.reload("roleTable"//, {
                         /* page:{
                              curr:1
                          }
                      }*/
                      )
                      //关闭弹窗
                      var index=parent.layer.getFrameIndex(window.name);
                      parent.layer.close(index);
                  }
            },"json")
            return false;//阻止默认表单提交
        })
    });
</script>
</body>
</html>
